The main objective of the seminar is to become familiar with the automated version control system Git and the remote repository GitHub.
Both tools are gaining more importance in the daily workflows of many researchers and university courses (e.g., STAT 545 course at the University of British Columbia, https://stat545.stat.ubc.ca/)
In this seminar we will learn how Git can be used to track changes to projects or files and how this version control is especially useful in collaborative projects through the use of hosting services such as GitHub. Understand their logic, functionality and power so that anyone can then explore them further.
Specifically we will learn:
The benefits of using an automated version control system
The advantages of integrating version control and hosting services
The basic workflow for using Git and GitHub from RStudio
For example, Git and GitHub can help us solve some everyday versioning problems that can be a bit of a nuisance:
- Overwriting a file
- Infinite final versions
- Mistakenly worked on a non-final version
- Creating “conflicting” copies when two people work at the same time
- Editions without tracking changes
| Introduction |
| What is Git |
| What is Github |
| Repositories & projects |
| Workflow in Git & GitHub |
| Branches |
| Some interesting links |
Git is an advanced version control system, similar to Microsoft Word’s “track changes”
Git takes “snapshots” of the project as it evolves and changes are saved
Git facilitates parallel work by several participants (central server vs. distributed server)
The original purpose of Git (software development) vs. the re-purposed
GitHub is an online hosting server for hosting Git-based projects that allows collaboration between different users (similar to Google Drive or Microsoft Teams but much more powerful)
GitHub advantages: working remotely, user-friendly interface, access your projects from any computer and the security of the cloud
All contributors agree that GitHub contains the main copy of the project
A repository is like a “container” in which to develop a project
There are four working areas (trees):
Working directory: where you are working. This tree is synchronised with the local files on your PC
Staging area: the intermediate zone between the working directory and the local repository. It is the draft zone. It records changes that are specified in the directory. It is also called Index
Local repository: where all changes of your PC are stored. It is also called HEAD
Remote repository: where all changes are stored in the cloud
A branch is basically a pointer to a specific commit
We can create a parallel “branch” to the project if we want to follow an independent line of work, either because it is different from the main one or to specifically develop a part
Branches allow you to work on the project without interfering with what your colleagues may be doing and then we can merge different branches
Session Info
Sys.time()
[1] "2021-11-04 16:10:39 CET"
git2r::repository()
Local: main C:/Users/julen/OneDrive - Universidad de Alcala/GitHub-collaborations/intro_git-github
Remote: main @ origin (https://github.com/Julenasti/intro_git-github.git)
Head: [0ea01cc] 2021-10-17: revert html
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] digest_0.6.27 R6_2.5.0 jsonlite_1.7.2
[4] git2r_0.28.0 magrittr_2.0.1 evaluate_0.14
[7] stringi_1.5.3 rlang_0.4.11 jquerylib_0.1.4
[10] bslib_0.2.5.1 rmarkdown_2.8 distill_1.2
[13] tools_4.0.5 stringr_1.4.0 xfun_0.22
[16] yaml_2.2.1 compiler_4.0.5 htmltools_0.5.1.1
[19] knitr_1.33 downlit_0.2.1 sass_0.4.0